package com.zxj.friend.controller.user;

import com.zxj.common.core.controller.BaseController;
import com.zxj.common.core.domain.R;
import com.zxj.common.core.domain.qo.PageQuery;
import com.zxj.common.core.domain.vo.PageVO;
import com.zxj.friend.domain.message.vo.MessageTextVO;
import com.zxj.friend.service.user.IUserMessageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/user/message")
@Tag(name = "用户消息相关接口", description = "用户消息相关接口")
public class UserMessageController extends BaseController {

    @Autowired
    private IUserMessageService userMessageService;

    @GetMapping("/list")
    @Operation(summary = "分页获取用户消息列表", description = "分页获取用户消息列表")
    public R<PageVO<MessageTextVO>> list(PageQuery pageQuery) {
        log.info("分页获取用户消息列表请求, 参数: {}", pageQuery);
        return R.ok(userMessageService.pageList(pageQuery));
    }

    @DeleteMapping("/deleteMessage")
    @Operation(summary = "删除消息", description = "删除消息")
    public R<Void> deleteMessage(Long textId) {
        log.info("删除消息请求, textId: {}", textId);
        return toR(userMessageService.deleteMessage(textId));
    }
}
